package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.OrderItem;
import edu.scau.mis.pos.mapper.OrderItemMapper;
import edu.scau.mis.pos.service.IOrderItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (OrderItem)表服务实现类
 *
 * @author CJW
 * @since 2024-04-04 00:22:03
 */
@Service("orderItemService")
public class OrderItemServiceImpl implements IOrderItemService {
    @Resource
    private OrderItemMapper orderItemMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param orderItemId 主键
     * @return 实例对象
     */
    @Override
    public OrderItem selectById(Long orderItemId) {
        return this.orderItemMapper.selectById(orderItemId);
    }

    /**
     * 查询指定行
     *
     * @param orderItem 筛选条件
     * @return 查询结果
     */
    @Override
    public List<OrderItem> selectList(OrderItem orderItem) {
        return this.orderItemMapper.selectList(orderItem);
    }

    /**
     * 新增数据
     *
     * @param orderItem 实例对象
     * @return 实例对象
     */
    @Override
    public OrderItem insert(OrderItem orderItem) {
        orderItem.setCreateTime(new Date());
        this.orderItemMapper.insert(orderItem);
        return orderItem;
    }

    /**
     * 修改数据
     *
     * @param orderItem 实例对象
     * @return 实例对象
     */
    @Override
    public OrderItem update(OrderItem orderItem) {
        orderItem.setUpdateTime(new Date());
        this.orderItemMapper.update(orderItem);
        return this.selectById(orderItem.getOrderItemId());
    }

    /**
     * 通过主键批量删除数据
     *
     * @param orderItemId 主键
     * @return 影响记录数
     */
    @Override
    public int deleteByIds(Long[] orderItemId) {
        return this.orderItemMapper.deleteByIds(orderItemId);
    }
}
